<?php
namespace app\redenvelope\validate;
use think\Validate;
class RedSend extends Validate {
    //验证字段
    protected $rule = [
        'amount' => ['require'],
        'message' => ['require'],
        'send_time' => ['require','number'],
        'red_type' => ['require'],
        'id' => ['require','number'],
    ];
    //返回消息
    protected $message = [
        'amount.require' => '金额必须',
        'message.require' => '留言必须',
        'send_time.require' => '发出红包的时间必须',
        'send_time.number' => '发出红包的时间不是数字',
        'red_type.require' => '红包的类型必须',
        'id.require' => 'id必须',
        'id.number' => 'id不是数字',
    ];

    // except_id 场景
    public function sceneExcept_id(){
        return $this->only(['amount','message','send_time','red_type']);
    }

    // only_id 场景
    public function sceneOnly_id(){
        return $this->only(['id']);
    }

    // all_field 场景
    public function sceneAll_field(){
        return $this->only(['id','amount','message','send_time','red_type']);
    }
}
